home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 January / pcwk_01_1999.iso / Wtestowe / Vistdstd / Install / Data.Z / VB Event Sample.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-20  |  3.2 KB  |  80 lines

  1. VERSION 4.00
  2. Begin VB.Form UserForm1 
  3.    Caption         =   "Event Sample"
  4.    ClientHeight    =   510
  5.    ClientLeft      =   1740
  6.    ClientTop       =   1860
  7.    ClientWidth     =   5505
  8.    Height          =   915
  9.    Left            =   1680
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   510
  12.    ScaleWidth      =   5505
  13.    Top             =   1515
  14.    Width           =   5625
  15.    Begin VB.TextBox TextBox1 
  16.       Height          =   285
  17.       Left            =   1680
  18.       TabIndex        =   1
  19.       Top             =   120
  20.       Width           =   3615
  21.    End
  22.    Begin VB.Label Label1 
  23.       Caption         =   "Received Event ----->"
  24.       Height          =   255
  25.       Left            =   120
  26.       TabIndex        =   0
  27.       Top             =   120
  28.       Width           =   1575
  29.    End
  30. Attribute VB_Name = "UserForm1"
  31. Attribute VB_Creatable = False
  32. Attribute VB_Exposed = False
  33. ' -------------------------------------------------------------------------
  34. ' Copyright (C) 1996 Visio Corporation
  35. ' You have a royalty-free right to use, modify, reproduce and distribute
  36. ' the Sample Application Files (and/or any modified version) in any way
  37. ' you find useful, provided that you agree that Visio has no warranty,
  38. ' obligations or liability for any Sample Application Files.
  39. ' -------------------------------------------------------------------------
  40. Option Explicit
  41. Dim g_Sink As EventSink         ' instance of class EventSink
  42. Dim g_Event As Visio.Event      ' Event object
  43. Dim docObj As Visio.Document
  44. Private Sub Form_Load()
  45. ' Developing Visio Solutions, Chapter 15, Handling Events in Visio
  46. ' This example demonstrates:
  47. '   creating/retrieving a Visio instance
  48. '   creating an instance of a sink object
  49. '   adding a new drawing
  50. '   retrieving the eventlist for a document
  51. '   adding an event that runs an add-on
  52. '   adding an event that sends a notification
  53. Dim eventsObj As Visio.EventList
  54.     ' Get the current instance of Visio if it is running or create a new one
  55.     ' vaoGetObject is a helper utility found in visreg.bas
  56.     If vaoGetObject() <> visOK Then
  57.         MsgBox "Unable to load Visio!"
  58.     End If
  59.         
  60.     ' Create an instance of the EventSink class
  61.     ' g_Sink in global to the form.
  62.     Set g_Sink = New EventSink
  63.     ' Create a new drawing.
  64.     Set docObj = g_appVisio.Documents.Add("")
  65.     ' Get the EventList collection of this document.
  66.     Set eventsObj = docObj.EventList
  67.     ' Add an Event object that will run an add-on when the event fires.
  68.     ' g_Event is global to this form
  69.     Set g_Event = eventsObj.Add(visEvtShape + visEvtAdd, visActCodeRunAddon, _
  70.         "ShowArgs.exe", "/args=Shape added!")
  71.        
  72.     ' Add event objects that will send notifications.
  73.     ' Add an Event object for the DocumentSaved event.
  74.     eventsObj.AddAdvise visEvtCodeDocSave, g_Sink, "", "Document Saved..."
  75.     ' Add an Event object for the ShapeDeleted event.
  76.     eventsObj.AddAdvise visEvtCodeShapeDelete, g_Sink, "", "Shape Deleted..."
  77.     ' Add an Event object for the PageAdded event.
  78.     eventsObj.AddAdvise (visEvtPage + visEvtAdd), g_Sink, "", "Page Added..."
  79. End Sub
  80.